package com.boot.commons;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    //响应码
    private int code;
    //响应消息
    private String msg;
    //响应结果
    private T data;

    public static <T> Result<T> success(T data){
        return new Result<>(Constants.SUCCESS_CODE,Constants.SUCCESS_MSG,data);
    }

    public static <T> Result<T> error(T data){
        return new Result<>(Constants.ERROR_CODE,Constants.ERROR_MSG,data);
    }
    public static <T> Result<T> warning(T data){
        return new Result<>(200,Constants.ERROR_MSG,data);
    }

}
